package cn.hloger.spider.demo.newsDemo.controller.api;

import cn.hloger.spider.demo.chatgptDemo.bean.req.ChatApiReq;
import cn.hloger.spider.demo.chatgptDemo.bean.resp.ChatApiResp;
import cn.hloger.spider.demo.newsDemo.service.NewsApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * TODO
 *
 * @author huanglong
 * @Description TODO
 * @data 2022/9/12
 */
@RestController
@RequestMapping("api/news")
public class NewsApiController {
    @Autowired
    private NewsApiService newsApiService;


    @PostMapping("/get")
    public ChatApiResp get(@RequestBody @Validated ChatApiReq req) {
        return newsApiService.getNews(req);
    }

    @GetMapping(value = "/view", produces = {"text/html;charset=UTF-8;", "application/json;"})
    public String view() {
        return newsApiService.view(null);
    }
}
